package com.wxq.product.web;

import com.wxq.product.service.SkuInfoService;
import com.wxq.product.vo.SkuItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author Jim
 * @date 3:05 下午 2022/4/9
 * @description 商品详情页
 * @email:huwmz04153277@126.com
 */
@Controller
public class ItemController {
    @Autowired
    private SkuInfoService skuInfoService;

    /**
     * sku详情页
     * @param skuId
     * @param model
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String item(@PathVariable("skuId") Long skuId, Model model){
        SkuItemVO skuItemVO = skuInfoService.item(skuId);
        model.addAttribute("skuItemVO",skuItemVO);
        //创建静态页面
        skuInfoService.createHtml(skuId);
        return "item";
    }

}
